package com.sun.sc.controller;

import com.sun.sc.service.CodeService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Reference
    private CodeService codeService;

    @RequestMapping("/create/{email}")
    public Boolean getCreateCode(@PathVariable String email){
        return codeService.createCode(email);
    }

    /**
     * 校验验证码是否正确，0正确1错误2超时
     */
    @GetMapping("/validate/{email}/{code}")
    public Integer validateCode(@PathVariable String email,@PathVariable String code){
        return codeService.validateCode(email,code);
    }
}
